/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package xdxn.editor.studio.geom;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * @author Cai Han
 * @creation 2015-6-18
 */
public class Polygon2D {

    private ArrayList<Point2D> points;

    private Polygon2D() {
        points = new ArrayList<>();
    }

    public Polygon2D( Point2D[] pts ) {
        this();
        assert (pts.length >= 3);
        points.addAll(Arrays.asList(pts));
    }

    public Polygon2D( ArrayList<Point2D> pts ) {
        this((Point2D[]) pts.toArray());
    }

    public Polygon2D( Polygon2D polygon ) {
        this(polygon.points);
    }

    /**
     * 判断点是否在多边形内部
     *
     * @param pt 传入判断点
     * @return 返回是否在多边形内部
     */
    public boolean isPointIn( Point2D pt ) {
        return false;
    }

    public Point2D GetVertex( int _index ) {
        if ( points.isEmpty() ) {
            return new Point2D(0 , 0);
        }
        if ( _index > points.size() ) {
            _index %= points.size();
        }
        return points.get(_index);
    }
    /**
     * 判断多边形是不是凸多边形
     */
    /**
     * 判断多边形是否是逆时针
     */
    /**
     * 多边形三角化
     */
    /**
     * 转为逆时针的多边形
     */
}
